package com.cgbl.cg.utils.city;

import com.alibaba.fastjson.JSON;
import com.cgbl.cg.R;
import com.robot.base.model.ConfirmOrderProductBean;
import com.robot.base.model.ShopCartBean;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class BeanTransferHelper {

    public static List<ConfirmOrderProductBean> cartsTransferConfirmOrderProduct(List<ShopCartBean> cartBeans) {
        List<ConfirmOrderProductBean> confirmOrderProductBeans = new ArrayList<>();
        for (ShopCartBean cart : cartBeans) {
            ConfirmOrderProductBean confirmOrderProductBean = new ConfirmOrderProductBean();
            confirmOrderProductBean.setProjectId(cart.getProductId());
            confirmOrderProductBean.setPrice(cart.getCourseInfoDTO().getRulingPrice());
            confirmOrderProductBean.setVipPrice(cart.getCourseInfoDTO().getClassVipPrice());
            confirmOrderProductBean.setProjectType(cart.getType());
            confirmOrderProductBean.setProjectName(cart.getCourseInfoDTO().getCourseName());
            confirmOrderProductBean.setProjectCover(Objects.requireNonNull(cart.getCourseInfoDTO().getInfoFileRespVOS()).get(0).getFilePath());
            confirmOrderProductBeans.add(confirmOrderProductBean);
        }
        return confirmOrderProductBeans;
    }

    public static List<ConfirmOrderProductBean> createConfirmOrderProductByCourse(String project, String projectType) {
        List<ConfirmOrderProductBean> confirmOrderProductBeans = new ArrayList<>();
        ConfirmOrderProductBean confirmOrderProductBean = new ConfirmOrderProductBean();
        confirmOrderProductBean.setProjectId(project);
        confirmOrderProductBean.setProjectType(projectType);
        confirmOrderProductBeans.add(confirmOrderProductBean);
        return confirmOrderProductBeans;
    }

    public static List<ConfirmOrderProductBean> createConfirmOrderProductByVip(String id, String price, String title) {

//        return JSON.parseArray("[{\"desc\":\"\",\"price\":\"200.00\",\"projectCover\":\"https://cgon-oss.oss-cn-hangzhou.aliyuncs.com/d89554cacc0beec2a916470031ab69960ae0776849d458cc653db8a43ffa779c.jpg\",\"projectId\":\"1249286274804142087\",\"projectName\":\"测试使用的第四课\",\"projectType\":\"1\",\"vipCover\":0,\"vipPrice\":\"0.00\"}]",ConfirmOrderProductBean.class);
        List<ConfirmOrderProductBean> confirmOrderProductBeans = new ArrayList<>();
        ConfirmOrderProductBean confirmOrderProductBean = new ConfirmOrderProductBean();
        confirmOrderProductBean.setProjectId(id);
        confirmOrderProductBean.setVipPrice(price);
        confirmOrderProductBean.setPrice(price);
        confirmOrderProductBean.setVipCover(R.mipmap.ic_vip_order_cover);
        confirmOrderProductBean.setProjectName(title);
        confirmOrderProductBean.setProjectType("3");
        confirmOrderProductBeans.add(confirmOrderProductBean);
        return confirmOrderProductBeans;
    }
}
